<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3.2.38/dist/vue.global.min.js"></script>
    <style>
        span {
            margin: 0 10px;
        }
        
        .isActive {
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <span v-for="(item,index) in movieList" :class="currentId === index ? 'isActive' : ''" @click="change(index)">
      {{item}}
    </span>
    </div>
</body>
<script>
    Vue.createApp({
        data() {
            return {
                currentId: 0,
                movieList: ['java', 'VUE', 'PYTHON', 'c语言']
            }
        },
        methods: {
            change(index) {
                console.log(index)
                this.currentId = index
            }
        }
    }).mount('#app')
</script>

</html>